/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
 * Description: header for supporting rtos crl revocation.
 * Author: guyiwen
 * Create: 2020-09-18
 */

#ifndef __CRL_REVOCATE_H_
#define __CRL_REVOCATE_H_

#include <linux/types.h>

/* Currently max revocation list is 64K  */
#define MAX_CRL_SIZE (64 * 1024)

#define MAX_CMS_SIZE 200000

typedef struct {
	char buf[MAX_CRL_SIZE];
	size_t size;
} crl_bundle_buffer;

#define CMS_RET_FORMAT(cms_ret) ((u_int32_t)(cms_ret))

#ifdef CONFIG_RTOS_MODULE_CERT_REVOCATE
/* Update kernel crl to system */
extern int kernel_update_crl(const char *crl, size_t size);

extern int kernel_verify_cms_data(const void *mod, unsigned long modlen,
				const void *sig, size_t sig_len);
#endif

#ifdef CONFIG_EULEROS_CMS_CBB
extern int mod_update_crl(const char *crl, size_t size);

extern int mod_verify_cms_data(const void *mod, unsigned long modlen,
				const void *sig, size_t sig_len);
#endif

extern unsigned char *get_crl_cert(void);

extern unsigned long get_crl_cert_size(void);

#ifdef CONFIG_RTOS_EXTRA_CERTIFICATE
extern unsigned char *get_crl_cert_second(void);

extern unsigned long get_crl_cert_size_second(void);
#endif

extern size_t get_crl_ondevice_size(void);

extern void set_crl_ondevice_size(size_t size);

extern void copyto_crl_ondevice_buf(const void *addr, size_t size);

extern char *get_crl_ondevice_buf(void);

#ifdef CONFIG_RTOS
extern const char system_extra_cert[];
extern const unsigned long system_extra_cert_used;
#endif

#ifdef CONFIG_RTOS_EXTRA_CERTIFICATE
extern const char system_extra_cert_second[];
extern const unsigned long system_extra_cert_used_second;
#endif

#ifdef CONFIG_EULEROS_CMS_CBB
extern const char system_certificate_list[];
extern const unsigned long system_certificate_list_size;
#endif

#endif
